package com.demoview.test.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.demoview.test.myapplication.fragment.LoginFragment;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recycler;
    private ShopBean shopBean;
    private DetailsStillsAdapter detailsStillsAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //自行判断翻转的问题，这里只是个demo
        getSupportFragmentManager().beginTransaction()
                .add(R.id.content, LoginFragment.newInstance())
                .commit();


//        recycler=findViewById(R.id.recycler_view);
//        //获取数据
//        getData();

    }
//    private void getData(){
//        OkGo.<String>get("https://livenew.yunbaozb.com/appapi/?service=Home.getShopList")
//                .params("uid", "9999")
//                .params("token", "9999")
//                .params("p", "1")
//                .execute(new StringCallback() {
//                    @Override
//                    public void onSuccess(Response<String> response) {
//                        System.out.print("成功==" + response);
//                        Gson gson = new Gson();
//                        shopBean = gson.fromJson(response.body(), new TypeToken<ShopBean>() {
//                        }.getType());
//                        List<ShopBean.DataBean.InfoBean.ListBean> dataBeans = shopBean.getData().getInfo().get(0).getList();
//                        detailsStillsAdapter = new DetailsStillsAdapter(MainActivity.this, dataBeans.size(), dataBeans);
//                        recycler.addItemDecoration(new SpacesItemDecoration(15));
//                        recycler.setAdapter(detailsStillsAdapter);
//                        recycler.setLayoutManager(new GridLayoutManager(MainActivity.this,2));
//
//                        }
//
//
//                });
//
//    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        SingleSocket.getInstance().disConnect();
    }
}
